home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Help trapping stdout from Unix system() c
- Date: 11 Apr 1996 16:20:38 GMT
- Organization: OpenVision
- Message-ID: <4kjbgm$7fm@spanky.pls.ov.com>
- References: <DpnGsD.Mo2@ul.ie>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article Mo2@ul.ie, vincent.walsh@ul.ie (Vincent Walsh) writes:
- >Hi All,
- >I have a problem and would appreciate is someone could help me!
- >
- >Within a C program I call another C program and I want to trap the output
- >of the second C program into a buffer. I tried using fopen, etc.. and
- >system() calls, but to no avail.
- >I also tried using popen to call the second C program and this trapped the
- >stdout into a buffer, but not stderr. Which means my buffer will tell me
- >the results if the second program works, but my buffer is empty if the
- >second program outputs to stderr!!
- >
- >I'm confused
- >
- >Thanks
- >Vincent Walsh
- >vincent.walsh@ul.ie
- >
-
-
- This request really belongs in comp.unix.programmer, but you should try:
-
- popen("your_command 2>&1", "r");
-
- The "2>&1" causes the shell that executes your program to direct stderr into
- stdout.
- Fletcher.Glenn@ov.com
-
-